import { createStore } from "vuex";
import axios from "axios";

const store = createStore({
  state() {
    return {
      items: []
    }
  },
  mutations: {
    setItems(state, items) {
      state.items = items
    }
  },
  actions: {
    async fetchItems({ commit }) {
      const response = await axios.get('https://yesno.wtf');
      commit('setItems', response.data);
    }
  }
})

export default store